#include<stdio.h>
#include<signal.h>
#include<stdlib.h>
#include<unistd.h>

void *handler_ptr;
void handler(int sig)
{
    printf("hello world\n");
    if(signal(SIGINT,handler_ptr) == SIG_ERR)
    {
        perror("fail to signal");
        exit(-1);
    }
}
int main()
{
    if((handler_ptr = signal(SIGINT,handler)) == SIG_ERR)
    {
        perror("fail to signal");
        exit(-1);
    }
    int i = 1;
    while(1)
    {
        sleep(1);
        printf("等待%ds\n",i++);
    }
    return 0;
}